<!DOCTYPE html>
<html lang="en">
<head>
    {% include "inc/common.html" %}
    <title>中搜API</title>
</head>
<body>
{% include "inc/header.html" %}

<div class="pure-form pure-form-aligned">
    <legend><h1>{{ title }} - 研发小哥儿有做这个页面的意愿……</h1></legend>
    <div class="pure-control-group">
        <label for="id_method">API</label>
        <select id="id_method">
            <option value="">接口方法名</option>
        </select>
    </div>
    <div class="pure-control-group">
        <label for="id_param">Param</label>
        <textarea name="name_param" id="id_param" rows="10" class="pure-u-17-24"></textarea>
    </div>
    <div class="pure-control-group">
        <label for="id_send"></label>
        <button class="pure-button pure-button-primary" id="id_send">Send <i class="fa fa-mouse-pointer"></i></button>
    </div>
    <div class="pure-control-group">
        <label for="id_result">Result</label>
        <pre name="" id="id_result" class="pure-u-17-24"></pre>
    </div>
</div>


{% include "inc/footer.html" %}

<script>
    $('#id_send').click(function(){
        $.ajax({
            url : '{% url "exec_dd_api" %}',
            data : {
                m : $('#id_method').val(),
                p : $('#id_param').val()
            }
        }).done(function (data) {
            $('#id_result').html(JSON.parse(data));
        });
    });
    $('#id_method').change(function(){
        var m = $('#id_method').val();
        $('#id_param').val(paramLib[m] || '{\n\n}');
    });

    var paramLib = {
    };

    $('#id_method').change();

</script>
</body>
</html>
